package Controllers;

import Impl.ClassServiceImpl;
import Impl.TeacherServiceImpl;
import com.alibaba.fastjson.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

@Controller
public class ClassDeleteController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    ClassServiceImpl classService;
	 @RequestMapping(value = "/ClassDelete", method = {RequestMethod.POST,RequestMethod.GET})
		@ResponseBody
		public JSONObject userRegister(HttpServletRequest request) throws Exception {
		 	ApplicationContext applicationContext=(ApplicationContext)request.getSession().getServletContext().getAttribute("ctx");
	        classService=(ClassServiceImpl)applicationContext.getBean("ClassServiceImpl");
			JSONObject obj = new JSONObject();
			String classid=request.getParameter("classid").replaceAll("'", "");
			classid=classid.replaceAll("\"","");
			classService.classDelete(Integer.parseInt(classid));
			obj.put("status", "OK");
			return obj;
		}

}
